
const app = getApp();
var api = require('../../config/api.js');
var util = require('../../utils/util.js');
Page({
  data: {
    userInfo: null,
    active: 1,
  },
  onChange(event) {
    wx.showToast({
      title: `切换到标签 ${event.detail.name}`,
      icon: 'none',
    });
  },
  onLoad: function (options) {
    var that = this;
    var status = false;
  },
  onShow: function () {
    wx.setNavigationBarTitle({ 
      title: '尽力而行'
    });
  },
  about: function (e) {
    wx.showModal({
      title: '提示',
      content: app.globalData.about || '',
      showCancel: false
    });
  },
  //下拉刷新（仅仅为示例，不是真实逻辑）
  onPullDownRefresh() {
    let that = this;
      wx.showNavigationBarLoading()//在标题栏中显示加载
      //刷新数据，刷新完成加载下边两个事件
      util.request(api.AuthUserInfo, { openid: app.globalData.openid }).then(function (res) {
        if (res.code === 0) {
          that.setData({
            userInfo : res.data
          })
          app.globalData.userInfo = res.data;
          
          wx.hideNavigationBarLoading() //完成停止加载
          wx.stopPullDownRefresh() //停止下拉刷新
        }
      })
  }
});
